package org.htmlparser.beans;

import java.awt.Dimension;
import java.awt.FontMetrics;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import java.io.Serializable;
import java.net.URL;
import java.net.URLConnection;
import javax.swing.JList;

public class HTMLLinkBean extends JList
  implements Serializable, PropertyChangeListener
{
  protected LinkBean mBean;

  public HTMLLinkBean()
  {
    getBean().addPropertyChangeListener(this);
  }

  public void addPropertyChangeListener(PropertyChangeListener paramPropertyChangeListener)
  {
    super.addPropertyChangeListener(paramPropertyChangeListener);
    getBean().addPropertyChangeListener(paramPropertyChangeListener);
  }

  protected LinkBean getBean()
  {
    if (this.mBean == null)
      this.mBean = new LinkBean();
    return this.mBean;
  }

  public URLConnection getConnection()
  {
    return getBean().getConnection();
  }

  public URL[] getLinks()
  {
    return getBean().getLinks();
  }

  public Dimension getMinimumSize()
  {
    FontMetrics localFontMetrics = getFontMetrics(getFont());
    return new Dimension(localFontMetrics.stringWidth("http://localhost"), localFontMetrics.getLeading() + localFontMetrics.getHeight() + localFontMetrics.getDescent());
  }

  public String getURL()
  {
    return getBean().getURL();
  }

  public void propertyChange(PropertyChangeEvent paramPropertyChangeEvent)
  {
    if (paramPropertyChangeEvent.getPropertyName().equals("links"))
      setListData(getBean().getLinks());
  }

  public void removePropertyChangeListener(PropertyChangeListener paramPropertyChangeListener)
  {
    super.addPropertyChangeListener(paramPropertyChangeListener);
    getBean().removePropertyChangeListener(paramPropertyChangeListener);
  }

  public void setConnection(URLConnection paramURLConnection)
  {
    getBean().setConnection(paramURLConnection);
  }

  public void setURL(String paramString)
  {
    getBean().setURL(paramString);
  }
}